from django.conf import settings
from rest_framework.routers import DefaultRouter, SimpleRouter

from backend.cews.api.AssetViewSet import AssetViewSet
from backend.cews.api.DepotViewSet import DepotViewSet
from backend.cews.api.ImteViewSet import ImteViewSet
from backend.cews.api.PartsViewSet import PartsViewSet
from backend.cews.api.PartVersionViewSet import PartVersionViewSet
from backend.cews.api.RepairOrderEDocViewSet import RepairOrderEDocViewSet
from backend.cews.api.RepairOrderPartVersionViewSet import \
    RepairOrderPartVersionViewSet
from backend.cews.api.RepairOrderTaskViewSet import RepairOrderTaskViewSet
from backend.cews.api.RepairViewSet import RepairViewSet
from backend.cews.api.StockItemEDocViewSet import StockItemEDocViewSet
from backend.cews.api.StockItemTaskViewSet import StockItemTaskViewSet
from backend.cews.api.StockItemViewSet import StockItemViewSet
from backend.cews.api.TaskViewSet import TaskViewSet
from backend.cews.api.VersionViewSet import VersionMasterViewSet
from backend.cews.api.PartsEDocViewSet import PartsEDocViewSet
from backend.cews.api.LogViewSet import LogViewSet
from backend.cews.api.ReportViewSet import ReportViewSet
from backend.cews.api.UploadViewSet import UploadViewSet
from backend.cews.api.MaintenanceRecordViewSet import MaintenanceRecordViewSet
from backend.cews.api.QRMapViewSet import QRMapViewSet
from backend.cews.api.QRMapLocationViewSet import QRMapLocationViewSet
from backend.cews.api.QRMapLocationViewSet import QRMapLocationCategoryViewSet
from backend.cews.api.StockItemImprovementWorkViewSet import StockItemImprovementWorkViewSet
from backend.cews.api.PartsImpWorkViewSet import PartsImpWorkViewSet
from backend.cews.api.RepairOrderImpWorkViewSet import RepairOrderImpWorkViewSet



from backend.eform.api.EformSchemaViewSet import EformSchemaViewSet
from backend.eform.api.views import EformFileViewSet
from backend.users.api.views import UserViewSet
from backend.users.api.GroupSettingsViewSet import GroupSettingsViewSet
from backend.gnsuser.api.GnsUserViewSet import GnsUserViewSet

from main.MainViewSet import MainViewSet

if settings.DEBUG:
    router = DefaultRouter()
else:
    router = SimpleRouter()

# users module
router.register("users", UserViewSet)
router.register("groupSettings", GroupSettingsViewSet)

# cews module
router.register("parts", PartsViewSet, basename="parts")
router.register("repair", RepairViewSet, basename="repair")
router.register("stock", StockItemViewSet, basename="stock")
router.register("assets", AssetViewSet, basename="assets")
router.register("depot", DepotViewSet, basename="depot")

router.register("tasks", TaskViewSet, basename="tasks")
router.register(
    "stockitemtasks", StockItemTaskViewSet, basename="stockitemtasks"
)

router.register(
    "repairordertasks", RepairOrderTaskViewSet, basename="repairordertasks"
)

router.register("imtes", ImteViewSet, basename="imtes")
router.register(
    "stockitemedocs", StockItemEDocViewSet, basename="stockitemedocs"
)

router.register(
    'repairorderedocs', RepairOrderEDocViewSet, basename='repairorderedocs'
)

router.register('versions', VersionMasterViewSet, basename='versions')
router.register('partversions', PartVersionViewSet, basename='partversions')
router.register(
    'repairorderpartversions',
    RepairOrderPartVersionViewSet,
    basename='repairorderpartversions'
)
router.register('partsedocs', PartsEDocViewSet, basename='partsedocs')
router.register('log', LogViewSet, basename='log')

router.register("report", ReportViewSet, basename="report")
router.register("upload", UploadViewSet, basename="upload")

router.register("qrmap", QRMapViewSet, basename="qrmap")
router.register("qrmaplocation", QRMapLocationViewSet, basename="qrmaplocation")
router.register("qrmaplocationcategory", QRMapLocationCategoryViewSet, basename="qrmaplocationcategory")

router.register(
    "stockitemimpwork", StockItemImprovementWorkViewSet, basename="stockitemimpwork"
)

router.register(
    "partsimpwork", PartsImpWorkViewSet, basename="partsimpwork"
)
router.register(
    "repairorderimpwork", RepairOrderImpWorkViewSet, basename="repairorderimpwork"
)


## Which record MTR old repair order records
router.register("maintenance", MaintenanceRecordViewSet, basename="maintenance")

# eform module
router.register("eformFiles", EformFileViewSet, basename="eformfiles")
router.register("eformschemas", EformSchemaViewSet, basename="eformschemas")
router.register('gnsusers', GnsUserViewSet, basename='gnsusers')

router.register("main", MainViewSet,basename='main')


app_name = "api"
urlpatterns = router.urls
